﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Classes
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Какую задачу вы бы хотели решить?");
            Console.WriteLine("1 - Employees");
            Console.WriteLine("2 - Students");
            Console.WriteLine("3 - Flights");
            Console.WriteLine("4 - Computers");
            Console.WriteLine("5 - Teas");
            Console.WriteLine("6 - DateTime");

            int task = Int32.Parse(Console.ReadLine());
            Console.Clear();
            if (task == 1)
            {
                FirstOption();
            }
            if (task == 2)
            {
                SecondOption();
            }
            if (task == 3)
            {
                ThirdOption();
            }
            if (task == 4)
            {
                FourthOption();
            }
            if (task == 5)
            {
                FifthOption();
            }
            if (task == 6)
            {
                DateTimeTask();
            }

        }

        static void FirstOption()
        {
            Employee[] tableEmployee = new Employee[5];
            for (int i = 0; i < 5; i++)
            {
                Employee newEmployee = new Employee();
                newEmployee.addEmployeeInfo();
                tableEmployee[i] = newEmployee;
            }
            int salarySum = 0;
            foreach (var employee in tableEmployee)
            {
                salarySum += employee.salary;
                employee.printInformation();
            }
            Console.WriteLine("Суммарная ЗП за месяц: {0}", salarySum);
            Console.ReadKey();
        }

        static void SecondOption()
        {
            Console.WriteLine("Введите кол-во студентов: ");
            int studentCount = Int32.Parse(Console.ReadLine());

            Students[] tableOfStudent = new Students[studentCount];
            for (int i = 0; i < studentCount; i++)
            {
                Students newStudent = new Students();
                newStudent.AddStudentInfo();
                tableOfStudent[i] = newStudent;
                Console.Clear();
            }
            foreach (var student in tableOfStudent)
            {
                if (student.AvarageMarks() > 67)
                {
                    student.PrintInfo();
                }
            }
            Console.ReadKey();
        }

        static void ThirdOption()
        {
            List<Flight> flights = new List<Flight>();
            string ch = "N";
            do
            {
                Console.Clear();
                Flight newFlight = new Flight();
                newFlight.AddFlightInfo();
                flights.Add(newFlight);
                Console.WriteLine("Would you like to add new flight? Y/N");
                ch = Console.ReadLine().ToUpper();
            } while (ch == "Y");
            Console.WriteLine("Choose destination point");
            string destinationPoint = Console.ReadLine();
            foreach (var planeFghts in flights)
            {
                if (destinationPoint == planeFghts.destination)
                {
                    planeFghts.PrintFlightInfo();
                }
            }
            Console.ReadKey();
        }

        static void FourthOption()
        {
            List<Laptop> computers = new List<Laptop>();
            string ch = "N";
            do
            {
                Console.Clear();
                Laptop newLaptop = new Laptop();
                newLaptop.addLaptopInfo();
                computers.Add(newLaptop);
                Console.WriteLine("Хотите добавить еще один ноутбук? Y/N");
                ch = Console.ReadLine().ToUpper();
            } while (ch == "Y");

            Console.Clear();
            Console.WriteLine("Подбор ноутбука");
            Laptop searchingLap = new Laptop();
            searchingLap.addLaptopInfo();
            List<Laptop> searchResults = new List<Laptop>();
            foreach (Laptop laptop in computers)
            {
                if (laptop.isEqualToLaptop(searchingLap))
                {
                    Console.WriteLine();
                    searchingLap.printLaptopInfo();
                    searchResults.Add(laptop);
                }
            }

            if (searchResults.Capacity == 0)
            {
                Console.WriteLine("Не найдено соответствующего ноутбука");
            }

            Console.ReadKey();
        }

        static void FifthOption()
        {
            List<Tea> Teas = new List<Tea>();
            
            string ch = "N";
            do
            {
                Console.Clear();
                Tea newTea = new Tea();
                newTea.AddTeaInfo();
                Teas.Add(newTea);
                Console.WriteLine("Хотите добавить еще один чай? Y/N");
                ch = Console.ReadLine().ToUpper();
            } while (ch == "Y");

            Console.Clear();

            foreach (Tea teaType in Teas)
            {
                int idx = Teas.IndexOf(teaType);
                Console.WriteLine("Вариант {0}", idx+1);
                teaType.PrintTeaInfo();
            }

            string choosenCountry;
            Console.WriteLine();
            Console.WriteLine("Укажите страну производителя чая:");
            choosenCountry = Console.ReadLine();
            foreach (var countries in Teas)
            {
                if (choosenCountry == countries.country)
                {
                    int idx = Teas.IndexOf(countries);
                    Console.WriteLine("Вариант {0}", idx + 1);
                    countries.PrintTeaInfo();
                }
            }

            Console.WriteLine();
            int teaVariant = 0;
            double orderedWeight = 0;
            double orderCoast = 0;
            Console.WriteLine("Выберите вариант чая, который вы хотите заказать");
            teaVariant = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Укажите количество, г:");
            orderedWeight = double.Parse(Console.ReadLine());
            
            foreach (var tea in Teas)
            {
                if ((teaVariant - 1) == Teas.IndexOf(tea))
                {
                    orderCoast = tea.price * orderedWeight/100;
                }
                else break;
                
            }
            Console.WriteLine("Cумма заказа: {0} грн", orderCoast);
            Console.ReadKey();

        }

        static void DateTimeTask()
        {
            DateTime today = new DateTime(2016,12,15);
            Console.WriteLine(today);
            
            DateTime dt = DateTime.Now;
            Console.WriteLine(dt);
            
            Console.WriteLine("Day of week: {0}", dt.DayOfWeek);
            Console.WriteLine("Short date: {0}", dt.ToShortDateString());
            Console.WriteLine("Short time: {0}", dt.ToShortTimeString());
            Console.WriteLine("Long Date: {0}", dt.ToLongDateString());
            Console.WriteLine("Long Time: {0}", dt.ToLongTimeString());
            Console.WriteLine("Specific view: {0}", dt.ToString("dd-$-MM-$-yyyy"));
            dt.AddDays(3);

            TimeSpan ts = TimeSpan.FromMinutes(100);
            Console.WriteLine("Interval in ts: {0}", ts.TotalMinutes);

            DateTime newYear = new DateTime(2017, 1, 1, 00, 00, 00);
            TimeSpan tsHours = TimeSpan.FromHours(4);
            DateTimeOffset tmOffset = new DateTimeOffset(2017, 1, 1, 00, 00, 00, tsHours);
            Console.WriteLine("Date Time offset 4h: {0}", tmOffset);


        }

    }

}
